package com.pfzy.utildemo.activity.im;

import com.pfzy.utildemo.ConstsValue;
import com.pfzy.lib.config.log.MyLog;

import java.util.ArrayList;
import java.util.List;

public class ChatPresenter implements ChatContract.Presenter {
    private ChatContract.View view;
    public List<Message> messages = new ArrayList<>();

    ChatPresenter(ChatContract.View view) {
        this.view = view;
        messages.add(new Message("别人", "你好帅", ConstsValue.MESSAGE_TYPE_RECEIVE, System.currentTimeMillis(),ConstsValue.MESSAGE_STATUS_INPROGRESS));
    }

    @Override
    public void sendMessage(String username, String message) {
        // 创建一条消息
//        EMMessage emMessage = EMMessage.createTxtSendMessage(message, username);
//        emMessage.setMessageStatusCallback(new EMCallBack() {
//            @Override
//            public void onSuccess() {
//                _log("发送成功");
//                view.onSendMessageSuccess();
//            }
//
//            @Override
//            public void onError(int code, String error) {
//                _log("发送失败");
//                view.onSendMessageFailed();
//            }
//
//            @Override
//            public void onProgress(int progress, String status) { }
//        });
        messages.add(new Message(username,message, ConstsValue.MESSAGE_TYPE_SEND,System.currentTimeMillis(),ConstsValue.MESSAGE_STATUS_INPROGRESS));
        view.onStartSendMessage();
//        EMClient.getInstance().chatManager().sendMessage(emMessage);
    }

    private void _log(String msg) {
        MyLog.logd("即时通讯: "+msg);
    }
}
